package com.bgs.travelapp.scenic.mapper;

import com.bgs.travelapp.mapper.BaseMapper;
import com.bgs.travelapp.scenic.entity.ScenicEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ScenicMapper extends BaseMapper<ScenicEntity> {
    /**
     * 根据城市id查询景区信息（前端管理）
     * @param cityParentId
     * @return
     */

    @Select("select * from scenic_entity where city_id = #{cityId} and del_flag = 0 order by id desc limit 0,6")
    @Results({
            @Result(property = "scenicName",column = "scenic_name"),
            @Result(property = "briefIntroduction",column = "brief_introduction"),
            @Result(property = "scenicAddress",column = "scenic_address"),
            @Result(property = "officialPhone",column = "official_phone"),
            @Result(property = "announcementInformation",column = "announcement_information"),
            @Result(property = "openingTime",column = "opening_time"),
            @Result(property = "provinceId",column = "province_id"),
            @Result(property = "preferentialTreatment",column = "preferential_treatment"),
            @Result(property = "delFlag",column = "del_flag"),
            @Result(property = "imageId",column = "image_id"),
            @Result(property = "homeImageId",column = "home_image_id"),
            @Result(property = "cityId",column = "city_id"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "updatetime"),
    })
    List<ScenicEntity> scenicAllByCirtId(@Param("cityId") Integer cityParentId);

    @Select("select * from scenic_entity where id = #{id}")
    @Results({
            @Result(property = "scenicName",column = "scenic_name"),
            @Result(property = "briefIntroduction",column = "brief_introduction"),
            @Result(property = "scenicAddress",column = "scenic_address"),
            @Result(property = "officialPhone",column = "official_phone"),
            @Result(property = "announcementInformation",column = "announcement_information"),
            @Result(property = "openingTime",column = "opening_time"),
            @Result(property = "provinceId",column = "province_id"),
            @Result(property = "preferentialTreatment",column = "preferential_treatment"),
            @Result(property = "delFlag",column = "del_flag"),
            @Result(property = "imageId",column = "image_id"),
            @Result(property = "homeImageId",column = "home_image_id"),
            @Result(property = "cityId",column = "city_id"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "updatetime"),
    })
    /**
     * 根据景区id查询景区信息
     */
    List<ScenicEntity> scenicDetailsAllById(Integer id);

    /**
     *根据景区id查询景区第一张图片
     * @param id
     * @return
     */
    @Select("select * from scenic_entity where id = #{id}")
    @Results({
            @Result(property = "scenicName",column = "scenic_name"),
            @Result(property = "briefIntroduction",column = "brief_introduction"),
            @Result(property = "scenicAddress",column = "scenic_address"),
            @Result(property = "officialPhone",column = "official_phone"),
            @Result(property = "announcementInformation",column = "announcement_information"),
            @Result(property = "openingTime",column = "opening_time"),
            @Result(property = "provinceId",column = "province_id"),
            @Result(property = "preferentialTreatment",column = "preferential_treatment"),
            @Result(property = "delFlag",column = "del_flag"),
            @Result(property = "imageId",column = "image_id"),
            @Result(property = "homeImageId",column = "home_image_id"),
            @Result(property = "cityId",column = "city_id"),
            @Result(property = "createTime",column = "create_time"),
            @Result(property = "updateTime",column = "updatetime"),
    })
    List<ScenicEntity> getScenicImageFirstById(Integer id);
}
